package com.heima.controller;

import com.heima.common.PageResult;
import com.heima.pojo.SkuClass;
import com.heima.pojo.dto.SkuClassPageQueryDTO;
import com.heima.pojo.vo.SkuClassVo;
import com.heima.service.SkuClassService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/api/vm-service/skuClass")
public class SkuClassController {

    @Autowired
    private SkuClassService skuClassService;

    @PostMapping
    public Boolean add(@RequestBody SkuClass skuClass){
        log.info(" 新增分类：{}",skuClass);
        return skuClassService.add(skuClass);
    }


    @GetMapping("/search")
    public PageResult skuQuery(SkuClassPageQueryDTO dto){
        log.info("分类搜索：{}",dto);
        return skuClassService.skuQuery(dto);
    }

    @GetMapping("/{classId}")
    public SkuClass findById(@PathVariable String classId){
        log.info("获取分类基本信息：{}",classId);
        return skuClassService.findById(classId);
    }

    @PutMapping("/{classId}")
    public Boolean update(@PathVariable String classId,@RequestBody SkuClass skuClass){
        log.info("修改分类：{},{}",classId,skuClass);
        return skuClassService.update(classId,skuClass);
    }

    @DeleteMapping("/{classId}")
    public void delete(@PathVariable String classId){
        log.info("删除分类：{}",classId);
        skuClassService.delete(classId);
    }


}
